import React, {Component} from 'react';
import {BrowserRouter as Router, Route, Link, MemoryRouter} from 'react-router-dom';
import {Provider} from 'react-redux';
import {createStore, applyMiddleware} from 'redux'
import logo from '../img/logo.svg';
import './App.css';
import profile from './profile';
import cview from './cview';
import message from './message';
import Footer from '../component/Footer';
import Header from "../component/Header";
import reducer from '../reducers/doMapA'
import thunkMiddleware from 'redux-thunk';
import Main from './Main'


class App extends Component {
    // constructor(props) {
    //     super(props);
    //     this.state = {
    //         title: '首页',
    //         api: 'httpllll'
    //     };
    //     // ES6 类中函数必须手动绑定
    //     this.handleChange = this.handleChange.bind(this);
    // }
    //
    // handleChange(val) {
    //     this.setState({
    //         title: val
    //     });
    // }

    render() {
        const store = createStore(
            reducer,
            applyMiddleware(thunkMiddleware)
        );
        store.subscribe(showSX)
        function showSX(){
            console.log(store.getState())
        }
        return (
            <Provider className="App" store={store}>
                <Router>
                    <div>
                        <Link to="/message">message...</Link>
                        <Footer ></Footer>
                        <p>dfgdfgdfg</p>
                        <Route exact path="/" component={Main}/>
                        <Route exact path="/main" component={Main}/>
                        <Route path="/cview" component={cview}/>
                        <Route path="/message" component={message}/>
                        <Route path="/profile" component={profile}/>
                    </div>
                </Router>

            </Provider>

        );
    }
}

export default App;
